<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;

use app\admin\model\ReasonModel;
use cmf\controller\AdminBaseController;
use think\Db;
use think\db\Query;

class ReasonController extends AdminBaseController
{
//    public function index()
//    {
//        if (!empty($content)) {
//            return $content;
//        }
//
//        $recordPostModel = new RecordModel();
//        $record         = $recordPostModel->where( 0)->select();
//        $this->assign('record', $record);
//        return $this->fetch();
//    }
    public function index()
    {


        /**搜索条件**/
        $name = $this->request->param('name');

        $reason = Db::name('reason')

            ->where(function (Query $query) use ($name) {
                if ($name) {
                    $query->where('name', 'like', "%$name%");
                }
            })
            ->order("id DESC")
            ->paginate(3);
        $reason->appends(['name' => $name]);
        // 获取分页显示
        $page = $reason->render();
        //
        $ReasonPostModel = new ReasonModel();
        $reason = $ReasonPostModel->where(0)->select();
        $this->assign("page", $page);
        $this->assign("reason", $reason);
        return $this->fetch();
    }
}